/**
 * @description   图片转base64
 * @param {*} url
 * @param {*} callback
 */
export function imgToBase64(url, callback) {
  const img = new Image();
  const canvas = document.createElement("canvas");
  const ctx = canvas.getContext("2d");

  img.crossOrigin = "anoymous";
  img.onload = function () {
    canvas.width = img.width;
    canvas.height = img.height;

    ctx.drawImage(img, 0, 0);
    callback(canvas.toDataURL());
  };
  img.src = url;
}
